/**
 * 
 */
package escola.dao.impl.database;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashSet;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;

import escola.dao.database.DatabaseDAO;

/**
 * @author Jonathan
 *
 */

@Repository("databaseDao")
public class DataBaseDaoImpl implements DatabaseDAO {

	private @Autowired @Qualifier("mainJdbcTemplate") JdbcTemplate jdbcTemplate;
	
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public Set<String> getDataBases() {
		return new HashSet<String>(jdbcTemplate.query("select databaseName from XDatabases", new RowMapper() {
			public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
				return rs.getString(1);
			}
		}));
	}

}
